// 导入：类型、接口、模块、组件、样式
import { Component } from "react";

// 类组件
class Index extends Component {
  state = {
    num: 0,
  };
  render() {
    return (
      <>
        <h1>num {this.state.num}</h1>
      </>
    );
  }

  componentDidMount() {
    // console.log("更新前：", this.state.num);
    // this.setState({ num: this.state.num + 1 });
    // console.log("更新后：", this.state.num);
    // document.onclick = () => {
    //   console.log("更新前：", this.state.num);
    //   this.setState({ num: this.state.num + 1 });
    //   console.log("更新后：", this.state.num);
    // };
    // setTimeout(() => {
    //   console.log("更新前：", this.state.num);
    //   this.setState({ num: this.state.num + 1 });
    //   console.log("更新后：", this.state.num);
    // });
  }
}

export default Index;
